package jsyntaxpane.actions.gui.renderer;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

import jsyntaxpane.annotations.Synthetic;

/**
 * {@link DefaultListCellRenderer} sintetico
 * 
 * @author takeshi
 */
public class SyntheticComboCellRenderer extends DefaultListCellRenderer {

    /**
     * {@inheritDoc}
     */
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        if (value instanceof Class<?> && ((Class<?>) value).isAnnotationPresent(Synthetic.class)) {
            Synthetic synth = ((Class<?>) value).getAnnotation(Synthetic.class);
            return super.getListCellRendererComponent(list, synth.value(), index, isSelected, cellHasFocus);
        }
        return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    }

}
